/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * plantilla.java
 *
 * Created on 31/10/2011, 12:00:51 AM
 */
package vista.panel.altas;

import controlador.EventoPanel;
import controlador.Listar;
import modelo.Nave;
import modelo.Referencia;
import modelo.Sustrato;
import modelo.SustratoNave;
import modelo.SustratoNavePK;

/**
 *
 * @author Elias Mendoza
 */
public class AltaSustrato extends javax.swing.JPanel {
  EventoPanel cargaPanel;
  Listar ce = new Listar();

  /** Creates new form plantilla */
  public AltaSustrato(EventoPanel cargaPanel) {
    this.cargaPanel = cargaPanel;
    initComponents();
    ce.llenaComponenteNave(nave);
    ce.llenaComponenteReferencia(referencia);
    

  }

  /** This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panel2 = new javax.swing.JPanel();
        jSplitPane1 = new javax.swing.JSplitPane();
        jLabel1Nombre = new javax.swing.JLabel();
        nombre = new javax.swing.JTextField();
        jSplitPane2 = new javax.swing.JSplitPane();
        jLabelConstitucion = new javax.swing.JLabel();
        constitucion = new javax.swing.JTextField();
        jSplitPane3 = new javax.swing.JSplitPane();
        jLabelDescripcion = new javax.swing.JLabel();
        descripcion = new javax.swing.JTextField();
        jSplitPane4 = new javax.swing.JSplitPane();
        jLabelUltModificacion = new javax.swing.JLabel();
        ultModificacion = new com.toedter.calendar.JDateChooser();
        jSplitPane5 = new javax.swing.JSplitPane();
        jLabelReferencia = new javax.swing.JLabel();
        referencia = new javax.swing.JComboBox();
        jSplitPane7 = new javax.swing.JSplitPane();
        jLabelNave = new javax.swing.JLabel();
        nave = new javax.swing.JComboBox();
        jPanel1 = new javax.swing.JPanel();
        jSplitPane6 = new javax.swing.JSplitPane();
        borrar = new javax.swing.JButton();
        siguiente = new javax.swing.JButton();

        setBackground(new java.awt.Color(255, 255, 255));
        setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Registrar Sustrato", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Maiandra GD", 1, 14))); // NOI18N
        setAutoscrolls(true);

        panel2.setBackground(new java.awt.Color(255, 255, 255));
        panel2.setAlignmentX(0.0F);
        panel2.setAlignmentY(0.0F);
        panel2.setAutoscrolls(true);
        panel2.setLayout(new java.awt.GridLayout(6, 1, 20, 10));

        jSplitPane1.setBackground(new java.awt.Color(255, 255, 255));
        jSplitPane1.setBorder(null);
        jSplitPane1.setDividerSize(0);
        jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        jLabel1Nombre.setBackground(new java.awt.Color(255, 255, 255));
        jLabel1Nombre.setFont(new java.awt.Font("Times New Roman", 1, 14));
        jLabel1Nombre.setForeground(new java.awt.Color(0, 153, 102));
        jLabel1Nombre.setText("Nombre:");
        jSplitPane1.setLeftComponent(jLabel1Nombre);

        nombre.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jSplitPane1.setRightComponent(nombre);

        panel2.add(jSplitPane1);

        jSplitPane2.setBackground(new java.awt.Color(255, 255, 255));
        jSplitPane2.setBorder(null);
        jSplitPane2.setDividerSize(0);
        jSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        jLabelConstitucion.setBackground(new java.awt.Color(255, 255, 255));
        jLabelConstitucion.setFont(new java.awt.Font("Times New Roman", 1, 14));
        jLabelConstitucion.setForeground(new java.awt.Color(0, 153, 102));
        jLabelConstitucion.setText("Constitución:");
        jSplitPane2.setLeftComponent(jLabelConstitucion);

        constitucion.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jSplitPane2.setRightComponent(constitucion);

        panel2.add(jSplitPane2);

        jSplitPane3.setBackground(new java.awt.Color(255, 255, 255));
        jSplitPane3.setBorder(null);
        jSplitPane3.setDividerSize(0);
        jSplitPane3.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        jLabelDescripcion.setBackground(new java.awt.Color(255, 255, 255));
        jLabelDescripcion.setFont(new java.awt.Font("Times New Roman", 1, 14));
        jLabelDescripcion.setForeground(new java.awt.Color(0, 153, 102));
        jLabelDescripcion.setText("Descripción:");
        jSplitPane3.setLeftComponent(jLabelDescripcion);

        descripcion.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jSplitPane3.setRightComponent(descripcion);

        panel2.add(jSplitPane3);

        jSplitPane4.setBackground(new java.awt.Color(255, 255, 255));
        jSplitPane4.setBorder(null);
        jSplitPane4.setDividerSize(0);
        jSplitPane4.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        jLabelUltModificacion.setBackground(new java.awt.Color(255, 255, 255));
        jLabelUltModificacion.setFont(new java.awt.Font("Times New Roman", 1, 14));
        jLabelUltModificacion.setForeground(new java.awt.Color(0, 153, 102));
        jLabelUltModificacion.setText("Ultima Modificación:");
        jSplitPane4.setLeftComponent(jLabelUltModificacion);
        jSplitPane4.setRightComponent(ultModificacion);

        panel2.add(jSplitPane4);

        jSplitPane5.setBackground(new java.awt.Color(255, 255, 255));
        jSplitPane5.setBorder(null);
        jSplitPane5.setDividerSize(0);
        jSplitPane5.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        jLabelReferencia.setBackground(new java.awt.Color(255, 255, 255));
        jLabelReferencia.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
        jLabelReferencia.setForeground(new java.awt.Color(0, 153, 102));
        jLabelReferencia.setText("Referencia:");
        jSplitPane5.setLeftComponent(jLabelReferencia);

        referencia.setPreferredSize(new java.awt.Dimension(23, 18));
        jSplitPane5.setRightComponent(referencia);

        panel2.add(jSplitPane5);

        jSplitPane7.setBackground(new java.awt.Color(255, 255, 255));
        jSplitPane7.setBorder(null);
        jSplitPane7.setDividerSize(0);
        jSplitPane7.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        jLabelNave.setBackground(new java.awt.Color(255, 255, 255));
        jLabelNave.setFont(new java.awt.Font("Times New Roman", 1, 14));
        jLabelNave.setForeground(new java.awt.Color(0, 153, 102));
        jLabelNave.setText("Nave:");
        jSplitPane7.setLeftComponent(jLabelNave);
        jSplitPane7.setRightComponent(nave);

        panel2.add(jSplitPane7);

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setLayout(new java.awt.GridBagLayout());

        borrar.setFont(new java.awt.Font("Maiandra GD", 1, 14));
        borrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/vista/img/borrar.png"))); // NOI18N
        borrar.setBorder(null);
        jSplitPane6.setRightComponent(borrar);

        siguiente.setFont(new java.awt.Font("Maiandra GD", 1, 14));
        siguiente.setIcon(new javax.swing.ImageIcon(getClass().getResource("/vista/img/siguiente.png"))); // NOI18N
        siguiente.setBorder(null);
        siguiente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                siguienteActionPerformed(evt);
            }
        });
        jSplitPane6.setLeftComponent(siguiente);

        jPanel1.add(jSplitPane6, new java.awt.GridBagConstraints());

        panel2.add(jPanel1);

        add(panel2);
    }// </editor-fold>//GEN-END:initComponents

  private void siguienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_siguienteActionPerformed
    // TODO add your handling code here:
    Sustrato s = new Sustrato();
    s.setConstitucion(constitucion.getText());
    s.setDescripcion(descripcion.getText());
    s.setNombre(nombre.getText());
    Referencia rs = (Referencia) referencia.getSelectedItem();
    Nave n = (Nave) nave.getSelectedItem();
    s.setReferencia(rs);
    SustratoNavePK snPK = new SustratoNavePK();
    snPK.setNaveFK(n);
    snPK.setSustratoFK(s);
    
    SustratoNave sn = new SustratoNave();
    sn.setPrimaryKey(snPK);
    
    cargaPanel.cargaPanelSuatratoGrupo(cargaPanel,sn);
  }//GEN-LAST:event_siguienteActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton borrar;
    private javax.swing.JTextField constitucion;
    private javax.swing.JTextField descripcion;
    private javax.swing.JLabel jLabel1Nombre;
    private javax.swing.JLabel jLabelConstitucion;
    private javax.swing.JLabel jLabelDescripcion;
    private javax.swing.JLabel jLabelNave;
    private javax.swing.JLabel jLabelReferencia;
    private javax.swing.JLabel jLabelUltModificacion;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JSplitPane jSplitPane2;
    private javax.swing.JSplitPane jSplitPane3;
    private javax.swing.JSplitPane jSplitPane4;
    private javax.swing.JSplitPane jSplitPane5;
    private javax.swing.JSplitPane jSplitPane6;
    private javax.swing.JSplitPane jSplitPane7;
    private javax.swing.JComboBox nave;
    private javax.swing.JTextField nombre;
    private javax.swing.JPanel panel2;
    private javax.swing.JComboBox referencia;
    private javax.swing.JButton siguiente;
    private com.toedter.calendar.JDateChooser ultModificacion;
    // End of variables declaration//GEN-END:variables
}
